
import java.io.*;
import java.util.*;

public class Main {
	
	public static void fill(int[][] arr, boolean [][] flag, int x, int y){
		int tox, toy, i, j;
		flag[x][y] = true;
		for (i=-1; i<=1; ++i)
			for (j=-1; j<=1; ++j)
			{
				if (i!=0 && j!=0) continue;
				tox = x+i;
				toy = y+j;
				if (tox<0 || toy<0 || tox==arr.length || toy==arr.length) continue;
				if (flag[tox][toy]==false && arr[tox][toy]==arr[x][y])
					fill(arr, flag, tox, toy);
			}		
	}
	
	public static void main(String[]arg)
	{		
		Scanner cin=new Scanner(System.in);
		int [][] arr;
		boolean [][] flag;
		int n, x, y;
		while (true){
			n=cin.nextInt();
			if (n==0) break;
			arr = new int[n][n];
			flag = new boolean[n][n];
			for (int i=0; i<n; ++i)
				for (int j=0; j<n; ++j)
					arr[i][j] = n;
			for (int i=1; i<n; ++i)
				for (int j=1; j<=n; ++j)
				{
					x = cin.nextInt()-1;
					y = cin.nextInt()-1;
					arr[x][y] = i;				
				}
			
			// debug:
//			System.out.println("debug:\n");
//			for (int i=0; i<n; ++i)
//			{
//				for (int j=0; j<n; ++j)
//					System.out.print(arr[i][j]+" ");
//				System.out.println("\n");
//			}
			
			for (int i=0; i<n; ++i)
				for (int j=0; j<n; ++j)
					flag[i][j] = false;
			int i, j;
			boolean []used = new boolean[n+1];
			for (i=0; i<=n; ++i) used[i] = false;
			for (i=0; i<n; ++i)
				for (j=0; j<n; ++j)
					if (used[arr[i][j]]==false){
						used[arr[i][j]] = true;						
						fill(arr, flag, i, j);
					}
			boolean ans = true;
			outside:
			for (i=0; i<n; ++i)
				for (j=0; j<n; ++j)
				{
					if (flag[i][j]==false)
					{
						ans = false;
						break outside;
					}
				}
			
			// debug:
//			System.out.println("debug:\n");
//			for ( i=0; i<n; ++i)
//			{
//				for ( j=0; j<n; ++j)
//					System.out.print(flag[i][j]+" ");
//				System.out.println("\n");
//			}
			
			if (ans) System.out.println("good");
			else System.out.println("wrong");
		}
        
	}
}
